using System.Collections.Generic;
using System.Runtime.Serialization;
namespace InSafetyAirServer.Model
{
    [DataContract]
    public class Vertex<T, E>
    {
        private T _object;
        private bool _mark;
        private IList<Edge<T, E>> _edgeList;

        public Vertex(T obj)
        {
            _object = obj;
            _mark = false;
            _edgeList = new List<Edge<T, E>>();
        }

        [DataMember]
        public T Object
        {
            get
            {
                return _object;
            }
            set
            {
                _object = value;
            }
        }

        public bool Mark
        {
            get
            {
                return _mark;
            }
            set
            {
                _mark = value;
            }
        }

        public IList<Edge<T, E>> Edges() //must return a List in order to be able to remove edges
        {
            return _edgeList;
        }

        public void AddEdge(Vertex<T, E> to, E data)
        {
            Edge<T, E> e = new Edge<T, E>(this, to, data);
            _edgeList.Add(e);
        }

        public int OutDegree()
        {
            return _edgeList.Count;
        }

        public void RemoveEdge(Edge<T, E> e)
        {
            _edgeList.Remove(e);
        }
    }

}